#include "BuildingObject.h"

#include "OgreFrameWork.h"
#include "CFGLoader.h"

#include "GameState.h"

#include "Util.h"



BuildingObject::BuildingObject():
    Object()
{
    //ctor

}

BuildingObject::~BuildingObject()
{
    //dtor
}
/** @brief getType
  *
  * @todo: document this function
  */
OBJ_TYPE BuildingObject::getType()
{
    return OBJ_TYP_BUILDING;
}


/** @brief init
  *
  * @todo: document this function
  */
void BuildingObject::init()
{
    /*
    Ogre::SceneManager *sceneMgr = OgreFramework::getSingletonPtr()->m_pRoot->getSceneManager("GameSceneMgr");

    OgreFramework::getSingletonPtr()->m_pLog->logMessage("BuildingObject::Init() : node creation");

    std::map<std::string, std::string> params = CFGLoader::loadRessourceFile(std::string(Ogre::String("../data/buildings/")+m_typeName+".cfg"));
    if (params.size()>1)
    {
        m_node = sceneMgr->getRootSceneNode()->createChildSceneNode();

        m_entity =  sceneMgr->createEntity("building_"+Ogre::StringConverter::toString(m_id++), params["Mesh"]);
        m_node->attachObject(m_entity);

    m_entity->setQueryFlags(QUERY_BUILDING);


        setYOffset(Ogre::StringConverter::parseReal(params["Yoffset"]));

        if (params.count("scale")>0)
        {

            float s = Ogre::StringConverter::parseReal(params["scale"]);
            m_node->setScale(Ogre::Vector3(0.01,s,0.01));
        }
        if (params.count("MatScript")>0)
        {
            m_entity->setMaterialName(params["MatScript"]);
        }

        if (params.count("crossable")>0)
        {
            if (params["crossable"].compare("1")==0)
            {
                GameManager::getInstance()->getLevelMgrPtr()->getBlockPtrAt(getPosition())->setCrossable(true);
            }
            else
            {
                GameManager::getInstance()->getLevelMgrPtr()->getBlockPtrAt(getPosition())->setCrossable(false);
            }


        }
    }
    else
    {
        OgreFramework::getSingletonPtr()->m_pLog->logMessage("WARNING :file for item "+m_typeName+" don't exist");
    }


    m_node->setPosition(addYtoVector2(getPosition(),m_Yoffset));

    */
}

/** @brief update
  *
  * @todo: document this function
  */
void BuildingObject::update(double timeSinceLastFrame)
{

}

/** @brief clear
  *
  * @todo: document this function
  */
void BuildingObject::clear()
{

}

